package solutions.face.easy;

import solutions.lib.BaseSolution;

import java.util.HashSet;
import java.util.Set;

/**
 * @author lizhidong
 * <a href="https://leetcode-cn.com/problems/palindrome-permutation-lcci/">面试题 01.04. 回文排列</a>
 */
public class Solution01_04 extends BaseSolution {

    public boolean canPermutePalindrome(String s) {
        Set<Character> set = new HashSet<>();
        for (char c : s.toCharArray()) {
            if (!set.remove(c)) {
                set.add(c);
            }
        }
        return set.size() < 2;
    }

    public static void main(String[] args) {
        Solution01_04 solution = new Solution01_04();
        System.out.println(solution.canPermutePalindrome("abdg"));
    }
}